﻿@model IEnumerable<DslamPort.Models.DslamPortModel>        
<!--Body-->
<div align="center">
    <h2>
        QUẢN LÝ PORT DSLAM - QUANG</h2>
</div>
<br>
<div class="container_12">
    <div class="grid_12">
        @if (TempData["msg"] != null)
        {                            
            <span class="notification n-success">@TempData["msg"]</span>
        }
        @if (TempData["error"] != null)
        {                            
            <span class="notification n-error">@TempData["error"]</span>
        }
        @using (Html.BeginForm("FindDslamPort", "DslamPortftth", FormMethod.Post, new { id = "FindDslamPort", name = "FindDslamPort" }))
        {
            <p style="text-align: left; width: 50%; padding-left: 5px">
                Đơn vị:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                @if (ViewBag.donvi != null)
                {                               
                    @Html.DropDownList("quan_huyen_id", ViewBag.donvi as SelectList, "---Chọn Đơn vị---", new { style = "width: 37%;" })                               
                }
                &nbsp;&nbsp;Trạng thái
                <select name="select_status" style="width: 22.3%;">
                    <option value="-1">Tất cả</option>
                    <option value="0"  @(ViewBag.find_select_status == "0" ? "selected" : "") >Trống</option>
                    <option value="1"  @(ViewBag.find_select_status == "1" ? "selected" : "") >Đã dùng</option>
                    <option value="2"  @(ViewBag.find_select_status == "2" ? "selected" : "") >Hỏng</option>
                </select>
            </p> 
            <p style="text-align: left; width: 54%; padding-left: 5px">
                Xã phường: @*@if (ViewBag.khuvuc != null)
                {                               
                    @Html.DropDownList("xa_phuong_id", ViewBag.khuvuc as SelectList, "---Chọn Xã phường---")                               
                
                }*@
                @if (ViewBag.khuvuc == null)
                {    
                    @Html.DropDownList("xa_phuong_id", Enumerable.Empty<SelectListItem>(), "---Chọn Xã phường---", new { style = "width: 34.3%;" })
                }
                else
                {
                    @Html.DropDownList("xa_phuong_id", ViewBag.khuvuc as SelectList, "---Chọn Xã phường---", new { style = "width: 34.3%;" })
                }
                &nbsp;&nbsp;Tìm kiếm
                <select name="select_option" style="width: 27%">
                    <option value="DslamPort.account_int"  @(ViewBag.find_selectbox == "DslamPort.account_int" ? "selected" : "") >
                        Account Internet</option>
                    <option value="DslamPort.account_mytv"  @(ViewBag.find_selectbox == "DslamPort.account_mytv" ? "selected" : "") >
                        Account Mytv</option>
                </select>
            </p>  
            <p style="text-align: left; width: 65%; padding-left: 4px">
                Tổ:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp @*@if (ViewBag.todanpho != null)
                {                               
                    @Html.DropDownList("todanpho_id", ViewBag.todanpho as SelectList, "---Chọn Tổ dân phố---", new { style = "width: 210px;" })                               
                
                }*@@*<input class="submit-green" type="submit" value="Lấy DSLAM"  />*@
                @if (ViewBag.todanpho == null)
                {    
                    @Html.DropDownList("todanpho_id", Enumerable.Empty<SelectListItem>(), "---Chọn Tổ dân phố---", new { style = "width: 28.5%" })
                }
                else
                {
                    @Html.DropDownList("todanpho_id", ViewBag.todanpho as SelectList, "---Chọn Tổ dân phố---", new { style = "width: 28.5%" })
                }
                &nbsp@*&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp*@
                <input type="text" class="input-short" name="timkiem" value="@ViewBag.find_textbox" style="width:30%" />
                <input class="submit-green" type="submit" value="Tìm kiếm" style="width: 13%" />
            </p> 
            <p style="text-align: left; width: 40%; padding-left: 5px">
                Dslam: &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
                @if (ViewBag.dslam == null)
                {    
                    @Html.DropDownList("system_id", Enumerable.Empty<SelectListItem>(), "---Chọn Dslam---", new { style = "width: 46.7%" })
                }
                else
                {
                    @Html.DropDownList("system_id", ViewBag.dslam as SelectList, "---Chọn Dslam---", new { style = "width: 46.7%" })
                }
            </p> 
@*<p style="text-align: left; width: 40%; padding-left: 5px">
                Trạng thái:
                <select name="select_status" style="width: 22.3%; margin-left: 7px">
                    <option value="-1">Tất cả</option>
                    <option value="0"  @(ViewBag.find_select_status == "0" ? "selected" : "") >Trống</option>
                    <option value="1"  @(ViewBag.find_select_status == "1" ? "selected" : "") >Đã dùng</option>
                    <option value="2"  @(ViewBag.find_select_status == "2" ? "selected" : "") >Hỏng</option>
                </select>
            </p>  *@  
@*<div class="bottom-spacing">
                Tìm kiếm:
                <select name="select_option" style="width: 22.3%; margin-left: 7px">
                    <option value="DslamPort.account_int"  @(ViewBag.find_selectbox == "DslamPort.account_int" ? "selected" : "") >
                        Account Internet</option>
                    <option value="DslamPort.account_mytv"  @(ViewBag.find_selectbox == "DslamPort.account_mytv" ? "selected" : "") >
                        Account Mytv</option>
                </select>
                <input type="text" class="input-short" name="timkiem" value="@ViewBag.find_textbox" style="width:20%; margin-left:20px" />
                <input class="submit-green" type="submit" value="Tìm kiếm" style="width: 8.5%; padding-left: 3px" />                
            </div>  *@ 
        }
        @using (Html.BeginForm("CheckedAction", "DslamPortftth", FormMethod.Post, new { id = "CheckedAction", name = "CheckedAction" }))
        {           
            <div class="module">
                <h2>
                    <span>@ViewBag.ip | @ViewBag.system_id</span></h2>
                <div class="module-table-body">
                    <div class="scrolling">
                        <div class="data-table" style="width: 250%">
                            <table id="myTable" class="tablesorter">
                                <thead>
                                    <tr>
                                        @* <th style="width: 3%;">
                                            STT
                                        </th>*@
                                        <th style="width: 3.6%;">
                                        </th>
                                        @*<th style="width: 1%;">
                                        </th>*@
                                        <th style="width: 3%;">
                                        </th>
                                        @*<th style="width: 8%;">
                                            Dslam
                                        </th>*@
                                        <th style="width: 2.5%;">
                                            Cổng
                                        </th>
                                        <th style="width: 5.8%;">
                                          @*  @if (ViewBag.dslam_type == 1)
                                            {
                                                <text>R/S |</text>
                                            }*@
                                            S/P | Svlan/Cvlan
                                        </th>
                                        <th style="width: 6.5%;">
                                            Account Internet
                                        </th>
                                        <th style="width: 8.5%;">
                                            Gói DV Internet
                                        </th>
                                        <th style="width: 6.5%;">
                                            Account Mytv
                                        </th>
                                        <th style="width: 7.5%;">
                                            Gói DV Mytv
                                        </th>
                                        @*<th style="width: 6.2%;">
                                            Hình thức Internet
                                        </th>*@
                                        <th style="width: 4%;">
                                            Mã KH
                                        </th>
                                        <th style="width: 10%;">
                                            Tên KH
                                        </th>
                                        @*<th style="width: 4%;">
                                            Trạng thái
                                        </th>*@
                                        <th>
                                            Địa chỉ
                                        </th>
                                        @*<th>
                                            Ngày ĐK
                                        </th>*@ @*<th style="width:130px;">Họ tên</th>*@
                                    </tr>
                                </thead>
                                <tbody>
                                    @{int stt = 0;}
                                    @foreach (var item in Model)
                                    {
                                        stt++;
                                        <tr>
                                            @*<td class="align-center">@stt
                                            </td>*@
                                            <td>
                                                @if (item.status != "2")
                                                {                                        
                                                    <a href="@Url.Action("RequestAction", "DslamPortftth", new { id = item.id, type = "bh" })" onClick="return confirm('Ban muon bao hong?')" title="Báo hỏng">
                                                        <img src="@Url.Content("~/Content/Body/Images/cross-on-white.gif")"  width="16" height="16" alt="edit" /></a><font>&nbsp;&nbsp;</font>
                                                    if (item.status == "1")
                                                    {
                                                    <a href="@Url.Action("RequestAction", "DslamPortftth", new { id = item.id, type = "dt" })" onClick="return confirm('Ban muon de trong?')" title="Để trống">
                                                        <img src="@Url.Content("~/Content/Body/Images/empty.png")"  width="16" height="16" alt="edit" /></a><font>&nbsp;&nbsp;</font>
                                                    }
                                                    else{
                                                    <text>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</text>
                                                    }
                                                    <a href="@Url.Action("EditDslamPort", "DslamPortftth", new { id = item.id, system_id = item.system_id, quan_huyen_id = item.quan_huyen_id, select_status = ViewBag.find_select_status, select_option = ViewBag.find_selectbox, timkiem = ViewBag.find_textbox })" title="Cập nhật">
                                                        <img src="@Url.Content("~/Content/Body/Images/pencil.gif")"  width="16" height="16" alt="edit" /></a>
                                                }
                                                else
                                                { 
                                                    <font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font>
                                                    <a href="@Url.Action("RequestAction", "DslamPortftth", new { id = item.id, type = "kp" })" onClick="return confirm('Ban muon khoi phuc?')" title="Khôi phục">
                                                        <img src="@Url.Content("~/Content/Body/Images/dongbo.jpg")"  width="18" height="18" alt="edit" /></a><font>&nbsp;&nbsp;</font>
                                                }
                                            </td>
                                            @if (item.status == "0")
                                            { 
                                                <td style="background: yellow">
                                                    Trống
                                                </td>
                                            }
                                            else if (item.status == "1")
                                            {
                                                <td>
                                                    Đã dùng
                                                </td>
                                            }
                                            else
                                            {
                                                <td style="background: red">
                                                    Hỏng
                                                </td>
                                            }
                                            @*<td>@Html.DisplayFor(modelItem => item.name)
                                            </td>*@
                                            <td>@Html.DisplayFor(modelItem => item.cong)
                                            </td>
                                            <td>
                                           
                                                @if (ViewBag.dslam_type == 1)
                                                {
                                                    @Html.DisplayFor(modelItem => item.rackid)<text>/</text>@Html.DisplayFor(modelItem => item.selfid)
                                                    <text>|</text> 
                                                }
                                                @if (Html.DisplayFor(modelItem => item.slot).ToString()=="")
                                                {
                                                     <text>TTDH</text> 
                                                }
                                                else{
                                                @Html.DisplayFor(modelItem => item.slot) <text>/</text> @Html.DisplayFor(modelItem => item.port)
                                                <text>|</text> @Html.DisplayFor(modelItem => item.vpi)<text>/</text> @Html.DisplayFor(modelItem => item.vci)
                                                }
                                                
                                            </td>
                                            <td>@Html.DisplayFor(modelItem => item.account_int)
                                            </td>
                                            <td>
                                                @Html.DisplayFor(modelItem => item.goidv_int)
                                                @if (item.hinh_thuc_int == "0")
                                                {                                                
                                                    <text>-Lưu lượng</text>                                             
                                                }
                                                else if (item.hinh_thuc_int == "1")
                                                {
                                                    <text>-Trọn gói</text>                                                
                                                }
                                                @if (item.trang_thai_int == "0")
                                                {
                                                    <text>/Khóa</text>
                                                }
                                                else if (item.trang_thai_int == "1")
                                                {
                                                    <text>/H.Động</text>
                                                }
                                                else if (item.trang_thai_int == "2")
                                                {
                                                    <text>/T.Ngưng</text>
                                                }
                                            </td>
                                            <td>@Html.DisplayFor(modelItem => item.account_mytv)
                                            </td>
                                            <td>
                                                @Html.DisplayFor(modelItem => item.goidv_mytv)
                                                @if (item.trang_thai_mytv == "0")
                                                {
                                                    <text>/Khóa</text>
                                                }
                                                else if (item.trang_thai_mytv == "1")
                                                {
                                                    <text>/H.Động</text>
                                                }
                                                else if (item.trang_thai_mytv == "2")
                                                {
                                                    <text>/T.Ngưng</text>
                                                }
                                            </td>
                                            @*<td>
                                                @if (item.hinh_thuc_int == "0")
                                                {                                                
                                                    <text>Lưu lượng</text>                                             
                                                }
                                                else if (item.hinh_thuc_int == "1")
                                                {
                                                    <text>Trọn gói</text>                                                
                                                }
                                            </td>*@
                                            <td>@Html.DisplayFor(modelItem => item.ma_kh)
                                            </td>
                                            <td>@Html.DisplayFor(modelItem => item.ten_kh)
                                            </td>
                                            @*<td>@Html.DisplayFor(modelItem => item.trang_thai_int)
                                            </td>*@
                                            <td>@Html.DisplayFor(modelItem => item.diachi_kh)
                                            </td>
                                            @*<td>@Html.DisplayFor(modelItem => item.ngay_dk_int)
                                            </td>*@
                                        </tr>
                                        <input type="hidden" name="dslam_type" value="@ViewBag.dslam_type" />
                                    }
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="pager" id="pager">
                        <div>
                            <img class="first" src="@Url.Content("~/Content/Body/Images/arrow-stop-180.gif")"  alt="first"/>
                            <img class="prev" src="@Url.Content("~/Content/Body/Images/arrow-180.gif")" alt="prev"/>
                            <input type="text" class="pagedisplay input-short align-center" />
                            <img class="next" src="@Url.Content("~/Content/Body/Images/arrow.gif")" alt="next"/>
                            <img class="last" src="@Url.Content("~/Content/Body/Images/arrow-stop.gif")" alt="last"/>
                            <select class="pagesize input-short align-center">
                                <option value="20" selected="selected">20</option>
                                <option value="30">30</option>
                                <option value="40">40</option>
                            </select>
                        </div>
                    </div>
                    <div style="clear: both">
                    </div>
                </div>
            </div> 
        }
    </div>
    <div style="clear: both;">
    </div>
</div>
@*<script type="text/javascript">
    $("#quan_huyen_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getDslamJson", "Dslam")',
            data: { quan_huyen_id: $("#quan_huyen_id > option:selected").attr("value"), Order: "ten_kv,name" },
            success: function (data) {
                var items = [];
                items.push("<option>---Chọn Dslam---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#system_id").html(items.join(' '));
            }
        })
    });
</script>*@
<script type="text/javascript">
    $("#quan_huyen_id").change(function () {
        $("#todanpho_id").html("<option value=''>---Chọn Tổ dân phố---</option>");
        $.ajax({
            type: "POST",
            url: '@Url.Action("getDslamJson", "DslamPortftth")',
            data: { quan_huyen_id: $("#quan_huyen_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option value=''>---Chọn Dslam---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#system_id").html(items.join(' '));
            }
        })
    });
    $("#quan_huyen_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getKhuvucJson", "DslamPortftth")',
            data: { quan_huyen_id: $("#quan_huyen_id > option:selected").attr("value"), Order: "ten" },
            success: function (data) {
                var items = [];
                items.push("<option value=''>---Chọn Xã phường---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#xa_phuong_id").html(items.join(' '));
            }
        })
    });
    $("#xa_phuong_id").change(function () {
        $("#system_id").html("<option value=''>---Chọn Dslam---</option>");
        $.ajax({
            type: "POST",
            url: '@Url.Action("getTodanphoJson", "DslamPortftth")',
            data: { xa_phuong_id: $("#xa_phuong_id > option:selected").attr("value"), Order: "ten" },
            success: function (data) {
                var items = [];
                items.push("<option value=''>---Chọn Tổ dân phố---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#todanpho_id").html(items.join(' '));
            }
        })
    });
    $("#xa_phuong_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getDslamByKhuvucJson", "DslamPortftth")',
            data: { xa_phuong_id: $("#xa_phuong_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option value=''>---Chọn Dslam---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#system_id").html(items.join(' '));
            }
        })
    });
    $("#todanpho_id").change(function () {
        $.ajax({
            type: "POST",
            url: '@Url.Action("getDslamByTodanphoJson", "DslamPortftth")',
            data: { todanpho_id: $("#todanpho_id > option:selected").attr("value"), Order: "name" },
            success: function (data) {
                var items = [];
                items.push("<option value=''>---Chọn Dslam---</option>");
                $.each(data, function () {
                    items.push("<option value='" + this.Value + "'>" + this.Text + "</option>");
                });
                $("#system_id").html(items.join(' '));
            }
        })
    });
</script>
